public class Solution415 {
    public String addStrings(String num1, String num2) {
        int len=Math.max(num1.length(),num2.length());
        int[] i1=new int[len];
        for (int i=0;i<num1.length();i++){
            i1[i]=num1.charAt(num1.length()-i-1)-'0';
        }
        int[] i2=new int[len];
        for (int i=0;i<num2.length();i++){
            i2[i]=num2.charAt(num2.length()-i-1)-'0';
        }
        int[] i3=new int[len+1];
        for (int i=0;i<len;i++){
            i3[i]+=i1[i]+i2[i];
            if (i3[i]>=10){
                i3[i+1]++;
                i3[i]-=10;
            }
        }
        int start=i3[len]==0?len-1:len;
        StringBuilder stringBuilder=new StringBuilder();
        for (int i=start;i>=0;i--){
            stringBuilder.append(i3[i]);
        }
        return stringBuilder.toString();
    }

    public static void main(String[] args) {
        System.out.println(new Solution415().addStrings("11","123"));
    }
}
